home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16827 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: news.interlog.com!news
  2. From: cjohnson@interlog.com (Colin Johnson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q: C++ read comma delim. text file & parse  How?
  5. Date: Fri, 12 Apr 1996 05:15:57 GMT
  6. Organization: InterLog Internet Services
  7. Message-ID: <4kkoug$ks7@steel.interlog.com>
  8. References: <316be5bd.148077@news.fix.net>
  9. NNTP-Posting-Host: ip94-139.tor.interlog.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. ryost@fix.net (Ron Yost) wrote:
  13.  
  14. >Hi all,
  15. >I'm new to C++ (BC++ 4.52) and have old 'legacy' prg I need to port to C++.
  16. >I have ascii text files that serve as 'look up tables' for conversion routines,
  17. >to re-map (transpose) MIDI note numbers in a standard MIDI song file, and need
  18. >to read in comma delimited data and ignore comments after each line.
  19.  
  20. >They're organized like this:
  21.  
  22. >** MIDIMAP DATA **              < Header; to make sure file is correct.
  23. >144,56,145,78  comments      <Want to read the 4 numbers in each row
  24. >145,34,144,45  comments      <and parse the documentary comments
  25. >145,78,146,78  comments      <after the rows. The comments are 35 chars max.
  26. >146,34,145,56  comments      <The data represents channel, note number.
  27.  
  28. >The files are 96 rows long, with four columns of numbers. I know I'll have to
  29. >convert the numbers from text to real numbers. These are to be read into 4
  30. >separate arrays, which will use the same index.
  31.  
  32. >Each row represents one MIDI note; 
  33. >First two numbers are an existing MIDI channel number and note number, say
  34. >144,56.
  35. >Second two numbers are what to change that to, say 145,78
  36.  
  37. >This came from GFA Basic on an Atari ST, and I used the RIGHT$ function in basic
  38. >to parse the comments, but how in C++?? Sorry if this seems simple and stupid!!
  39.  
  40. >Any help would be appreciated! THANKS a bunch!
  41.  
  42. >Ron Yost <ryost@fix.net>
  43. >Paso Robles, CA
  44.  
  45. I would suggest taking advantage of the strcspn function. This will return the
  46. length of the leftmost substring that does not have the letters specified, in
  47. your case it looks like a space. You could then copy this into another string.
  48.  
  49. Good Luck.
  50.  
  51. Colin Johnson
  52. ---------------------------------------------------------------
  53. Write a program so that an idiot can use it and only idiots will
  54. want to use it.
  55.  
  56.